function plotCondition(node)
c = node.getConstraint();
if c ~= NaN
    X = node.getPosition();
    x = X(1);
    y = X(2);
    if ~c.isFree(0)
        if c.getValue(0)~=0
            plotDisplacement(x,y,'>',...
                c.getValue(0))
        else
            plotSupport(x,y,'>')
        end
    end
    if ~c.isFree(1)
        if c.getValue(1)~=0
            plotDisplacement(x,y,'^',...
                c.getValue(1))
        else
            plotSupport(x,y,'^')
        end
    end
end
end

function plotSupport(x,y,dir)
h = 0.04;
w = 0.02;
xa = -w/2;
ya = -h;
xb = w/2;
yb = -h;
r = 0;
if strcmp(dir,'<')
    r = pi/2;
elseif strcmp(dir,'^')
    r = 0;
elseif strcmp(dir,'>')
    r = -pi/2;
elseif strcmp(dir,'v')
    r = pi;
end
Q = [cos(r) -sin(r);sin(r) cos(r)];
A = Q*[xa;ya];
B = Q*[xb;yb];
% line([x x+A(1)],[y y+A(2)]);
% line([x x+B(1)],[y y+B(2)]);
% line([x+A(1) x+B(1)],[y+A(2) y+B(2)]);
fill([x x+A(1) x+B(1)],[y y+A(2) y+B(2)],'r');
end

function plotDisplacement(x,y,dir,d)
h = 0.04;
w = 0.02;
l = 0.2;
xa = -w/2;
ya = -h;
xb = w/2;
yb = -h;
r = 0;
if strcmp(dir,'<')
    r = pi/2;
    xc = x - l;
    yc = y;
elseif strcmp(dir,'^')
    r = 0;
    xc = x;
    yc = y + l;
elseif strcmp(dir,'>')
    r = -pi/2;
    xc = x + l;
    yc = y;
elseif strcmp(dir,'v')
    r = pi;
    xc = x;
    yc = y - l;
end
Q = [cos(r) -sin(r);sin(r) cos(r)];
A = Q*[xa;ya];
B = Q*[xb;yb];
fill([xc xc+A(1) xc+B(1)],[yc yc+A(2) yc+B(2)],'r');
line([x xc],[y yc]);
text((x+xc)/2,(y+yc)/2,['d=' num2str(d)]);
end
